/**
 * 
 */
package com.cqan.entity.account;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.cqan.entity.pk.IdEntity;

/**
 * @author slaton
 *
 * 上午11:37:40
 */
@Entity
//表名与类名不相同时重新定义表名.
@Table(name = "SYS_PERMISSION")
//默认的缓存策略.
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Permission extends IdEntity {

	private String name;
	
	private Resource resource;
	
	
	private Operate operate;
	
	/**
	 * 状态:0:删除,1:正常
	 */
	private Integer status;
	
	/**
	 * 描述
	 */
	private String description;
	
	/**
	 * 权限代码
	 */
	private String code;

	
	public String getCode() {
		return code;
	}

	
	public void setCode(String code) {
		this.code = code;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne 
    @JoinColumn(name = "resid") 
	public Resource getResource() {
		return resource;
	}
	
	public void setResource(Resource resource) {
		this.resource = resource;
	}

	@ManyToOne(cascade = {CascadeType.REFRESH },fetch=FetchType.LAZY, optional = false)  
    @JoinColumn(name = "operid") 
	public Operate getOperate() {
		return operate;
	}

	public void setOperate(Operate operate) {
		this.operate = operate;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	
	
}
